<!-- 单个设备 -->
<template>
    <div class="deviceItem">
        <div class="header">
            <iconBorder
                outWidth="20px"
                inWidth="10px"
                bgColor="#5FB17E"
                imgSrc="newIndex/zaixian.png"
                :isCenter="false"
                style="margin-top: 6px; text-align: left; margin-left: 5px"
            ></iconBorder>
            <div class="header-center">{{ item.eq_name }}</div>
            <div class="rightImg">
                <img src="@/assets/images/newIndex/refresh.png" />
                <label></label>
                <img src="@/assets/images/newIndex/wifi1.png" />
            </div>
        </div>
        <div class="body">
            <!-- 空调样式 -->
            <div class="kongtiao" v-if="item.eq_type == 'KT'">
                <div class="ktHeader ktOpen">
                    <img src="@/assets/images/newIndex/jian.png" @click.stop="jianFun()" />
                    <span>{{ item.end_value }}℃</span>
                    <img src="@/assets/images/newIndex/jia.png" @click.stop="jiaFun()" />
                </div>
                <div class="temp">
                    <label>室温：{{ item.end_value }}℃</label>
                    <span>
                        <img src="@/assets/images/newIndex/17.png" />
                        <img src="@/assets/images/newIndex/fengsu.png" />
                    </span>
                </div>
                <div class="gl">
                    <p>电量：200000.00kwh</p>
                    <p>功率：1500w</p>
                </div>
                <div class="btns">
                    <div class="btn">
                        <iconBorder
                            outWidth="24px"
                            inWidth="16px"
                            bgColor="#5694D4"
                            imgSrc="newIndex/8.png"
                            marginTop="4px"
                            :isCenter="false"
                        ></iconBorder>
                    </div>
                    <div class="btn">
                        <iconBorder
                            outWidth="24px"
                            inWidth="9px"
                            bgColor="#5694D4"
                            imgSrc="newIndex/9.png"
                            marginTop="-4px"
                            :isCenter="true"
                        ></iconBorder>
                    </div>
                    <div class="btn">
                        <iconBorder
                            outWidth="24px"
                            inWidth="16px"
                            bgColor="#5694D4"
                            imgSrc="newIndex/11.png"
                            marginTop="4px"
                            :isCenter="false"
                        ></iconBorder>
                    </div>
                    <div class="btn">
                        <iconBorder
                            outWidth="24px"
                            inWidth="16px"
                            bgColor="#5694D4"
                            imgSrc="newIndex/10.png"
                            marginTop="4px"
                            :isCenter="false"
                        ></iconBorder>
                    </div>
                    <div class="btn">
                        <iconBorder
                            outWidth="24px"
                            inWidth="16px"
                            bgColor="#5694D4"
                            imgSrc="newIndex/close.png"
                            marginTop="4px"
                            :isCenter="false"
                        ></iconBorder>
                    </div>
                </div>
            </div>
            <!-- 路灯样式 -->
            <div class="ludeng" v-else-if="item.type == 'LDKZQ'">
                <img src="@/assets/images/newIndex/gz.png" class="ludImg" />
                <img src="@/assets/images/newIndex/18.png" class="ludImg1" v-if="item.status == 2" />
                <div class="lux">
                    <p>10000</p>
                    <p>光照值LUX</p>
                </div>
                <div class="data">
                    <p><label>电量：</label>200000.00kwh</p>
                    <p><label>电流：</label>1200A</p>
                    <p><label>电压：</label>1000V</p>
                    <p><label>功率：</label>500W</p>
                </div>
                <div class="close">
                    <iconBorder
                        outWidth="28px"
                        inWidth="16px"
                        bgColor="#8F97AA"
                        imgSrc="newIndex/close.png"
                        marginTop="6px"
                        :isCenter="false"
                    ></iconBorder>
                </div>
            </div>
            <!-- 照明样式 -->
            <div class="zhaoming" v-else>
                <p class="left">总电量：</p>
                <p class="center">200000.00kwh</p>
                <div class="imgList">
                    <img :src="getZhaoMingImg()" />
                    <img :src="getZhaoMingImg2()" />
                </div>
                <div class="text">
                    <div class="leftText">
                        <p>照明电量：10000.00kwh</p>
                        <p>回路功率：500W</p>
                    </div>
                    <div class="rightIcon">
                        <radioBtn :defaultCheck="true"></radioBtn>
                    </div>
                </div>
                <div class="line"></div>
                <div class="text">
                    <div class="leftText">
                        <p>照明电量：10000.00kwh</p>
                        <p>回路功率：500W</p>
                    </div>
                    <div class="rightIcon"><radioBtn :defaultCheck="false"></radioBtn></div>
                </div>
            </div>
        </div>
    </div>
</template>

<script>
import iconBorder from '@/components/newIndex/iconBorder'
import radioBtn from '@/components/newIndex/radioBtn.vue'
export default {
    props: ['item'],
    components: {iconBorder, radioBtn},
    data() {
        return {}
    },
    mounted() {
        // const item = this.item
        // console.log(item, '设备信息....')
    },
    methods: {
        jianFun() {
            console.log(1)
        },
        jiaFun() {
            console.log(2)
        },
        getZhaoMingImg2() {
            const item = this.item
            let img = ''
            if (item.status == 1) {
                img = require(`@/assets/images/newIndex/2.1.png`)
            } else {
                img = require(`@/assets/images/newIndex/2.png`)
            }
            return img
        },
        getZhaoMingImg() {
            const item = this.item
            let img = ''
            if (item.status == 1) {
                img = require(`@/assets/images/newIndex/1.1.png`)
            } else if (item.status == 2) {
                img = require(`@/assets/images/newIndex/1.2.png`)
            } else {
                img = require(`@/assets/images/newIndex/1.png`)
            }
            return img
        },
        getImg() {
            try {
                const src = this.imgSrc
                const img = require(`@/assets/images/${src}`)
                console.log(src, img, 'src....')
                return img
            } catch (error) {
                console.log(error)
                return ''
            }
        }
    }
}
</script>
<style lang="scss" scoped>
.deviceItem {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    .header {
        background: linear-gradient(to right, #557fe5, #74c5eb);
        height: 32px;
        line-height: 32px;
        width: 100%;
        border-top-left-radius: 8px;
        border-top-right-radius: 8px;
        display: flex;
        align-content: center;
        justify-content: center;
        .header-center {
            flex: 1;
            text-align: center;
            margin: 0 5px;
            white-space: nowrap; /* 不换行 */
            overflow: hidden; /* 超出部分隐藏 */
            text-overflow: ellipsis; /* 超出部分显示省略号 */
            color: #fff;
            font-size: 16px;
        }
        .rightImg {
            height: 20px;
            background-color: #fff;
            border-radius: 25px;
            margin-top: 7px;
            margin-right: 5px;
            line-height: 20px;
            padding: 0 5px;
            img {
                height: 13px;
                cursor: pointer;
            }
            label {
                background-color: #333;
                width: 1px;
                height: 15px;
                display: inline-block;
                margin: 0 5px;
            }
        }
    }
    .body {
        background: linear-gradient(to bottom, #cad7fb, #f1f3f8);
        height: calc(100% - 32px);
        .kongtiao {
            display: flex;
            padding: 10px;
            flex-direction: column;
            .ktHeader {
                height: 65px;
                background-size: 100% !important;
                width: 92%;
                margin: 0 4%;
                line-height: 45px;
                text-align: center;
                span {
                    margin: 0 5px;
                    float: left;
                }
                img {
                    width: 16px;
                    height: 16px;
                    display: block;
                    float: left;
                    margin-top: 15px;
                    cursor: pointer;
                    &:first-child {
                        margin-left: 35%;
                    }
                }
                div {
                    background-color: red;
                    width: 60px;
                }
            }
            .ktOpen {
                background: url('@/assets/images/newIndex/kt1.png') no-repeat top left;
                color: #fff;
            }
            .temp {
                display: flex;
                border-bottom: 1px solid #979eaf;
                text-align: left;
                margin: 10px auto;
                height: 20px;
                width: 94%;
                padding-bottom: 5px;
                span {
                    text-align: right;
                    flex: 1;
                    img {
                        height: 14px;
                        margin-left: 10px;
                        cursor: pointer;
                    }
                }
            }
            .gl {
                margin: 10px auto;
                width: 90%;
                text-align: left;
                p {
                    font-size: 14px;
                    color: #000;
                    line-height: 25px;
                }
            }
            .btns {
                background-color: #fff;
                border-radius: 25px;
                height: 30px;
                width: 90%;
                margin: 0 auto;
                display: flex;
                justify-content: center;
                align-items: center;
                .btn {
                    position: relative;
                    width: 20%;
                    text-align: center;
                    cursor: pointer;
                    &:nth-child(5) {
                        &::before {
                            content: '';
                            position: absolute;
                            left: 0;
                            top: 0;
                            height: 24px;
                            width: 1px;
                            background-color: #979eaf;
                        }
                    }
                }
            }
        }
        .ludeng {
            position: relative;
            height: 100%;
            width: 100%;
            overflow: hidden;
            .ludImg {
                width: 135px;
                position: absolute;
                bottom: -25px;
                left: 15px;
                z-index: 1;
            }
            .ludImg1 {
                position: absolute;
                bottom: 33px;
                left: 65px;
                z-index: 1;
            }
            .lux {
                position: absolute;
                top: 93px;
                left: 22px;
                z-index: 2;
                color: #406ac7;
                text-align: center;
                p {
                    font-size: 14px;
                    font-weight: bold;
                    margin-left: 0;
                    &:last-child {
                        font-size: 11px;
                        font-weight: normal;
                        margin-left: 3px;
                    }
                }
            }
            .data {
                position: absolute;
                bottom: 5px;
                right: 5px;
                background-color: #f1f6fa;
                color: #000;
                font-size: 12px;
                padding: 5px;
                border-radius: 10px;
                width: 62%;
                z-index: 2;
                label {
                    color: #000;
                }
            }
            .close {
                position: absolute;
                bottom: 10px;
                right: 10px;
                cursor: pointer;
                z-index: 3;
            }
        }
        .zhaoming {
            position: relative;
            height: 100%;
            width: 100%;
            overflow: hidden;
            .left {
                text-indent: 20px;
                line-height: 25px;
                font-size: 14px;
            }
            .center {
                width: 100%;
                text-align: center;
                font-size: 16px;
                font-weight: bold;
            }
            .imgList {
                position: relative;
                margin: 10px 5%;
                width: 90%;
                height: 70px;
                display: flex;
                gap: 20px;
                justify-content: center;
                align-items: center;
                img {
                    height: 70px;
                }
            }
            .line {
                height: 1px;
                width: 100%;
                background-color: #9da3b0;
                width: 90%;
                margin: 0 auto;
            }
            .text {
                display: flex;
                font-size: 12px;
                height: 40px;
                width: 90%;
                margin: 5px auto;
                .leftText {
                    flex: 1;
                    text-align: left;
                }
                .rightIcon {
                    width: 60px;
                    text-align: right;
                    display: flex;
                    justify-content: center;
                    padding-top: 5px;
                    zoom: 0.8;
                }
            }
        }
    }
}
</style>